/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
 * -*- coding: utf-8 -*-
 *
 * Copyright (C) 2020 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef KeyboardWaylandManager_H
#define KeyboardWaylandManager_H

#include <QObject>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QWidget>

#include <QDBusConnection>
#include <QDBusInterface>
#include <QDBusReply>

#include <QTimer>
#include <QtX11Extras/QX11Info>

#include <QGSettings/qgsettings.h>
#include <QApplication>

#include "manager.h"
#include "xeventmonitor.h"
#include "keyboard-xkb.h"
#include "keyboard-widget.h"
#include "usd_base_class.h"

#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
#include <X11/extensions/xf86misc.h>
#endif

#ifdef HAVE_X11_EXTENSIONS_XKB_H
#include <X11/XKBlib.h>
#include <X11/keysym.h>
#endif

class KeyboardXkb;
class KeyboardWaylandManager : public Manager
{
    Q_OBJECT
private:
    KeyboardWaylandManager()=delete;
    KeyboardWaylandManager(KeyboardWaylandManager&)=delete;
    KeyboardWaylandManager&operator=(const KeyboardWaylandManager&)=delete;
    KeyboardWaylandManager(QObject *parent = nullptr);


public:
    ~KeyboardWaylandManager();
    static KeyboardWaylandManager *KeyboardWaylandManagerNew();
    bool start();
    void stop ();
public Q_SLOTS:
    void start_keyboard_idle_cb ();
    void apply_settings  (QString);
private:
    friend void apply_repeat     (KeyboardWaylandManager *manager);

private:
    QTimer                 *time;
    static KeyboardWaylandManager *mKeyboardWaylandManager;
    QGSettings             *settings;
    QGSettings             *ksettings;
    int                     old_state;
    bool                    stInstalled;

    KeyboardWidget*         m_statusWidget;

};

#endif // KeyboardWaylandManager_H
